package com.bnyy.medicalHousekeeper.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bnyy.medicalHousekeeper.GlideHelper;
import com.bnyy.medicalHousekeeper.R;
import com.bnyy.medicalHousekeeper.bean.Goods;
import com.bnyy.common.adapter.BaseNormalListAdapter;

/**
 * Author : 关炳鹏
 * Description :
 * Date : 2023/2/3
 **/
public class IndexGoodsAdapter extends BaseNormalListAdapter<Goods, IndexGoodsAdapter.ViewHolder>{

    public IndexGoodsAdapter(Context context, OnItemClickListener<Goods> onItemViewClickListener) {
        super(context, onItemViewClickListener);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(inflater.inflate(R.layout.item_index_goods, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);

        Goods goods = getData(position);

        GlideHelper.setRoundImage(mContext, goods.getGoods_image(), holder.ivGoods);
        holder.tvGoods.setText(goods.getGoods_name());
    }

    public static class ViewHolder extends BaseNormalListAdapter.ViewHolder {

        TextView tvGoods;
        ImageView ivGoods;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            tvGoods = itemView.findViewById(R.id.tv_goods_name);
            ivGoods = itemView.findViewById(R.id.iv_goods);
        }
    }
}
